package com.party.core.service.commune.impl;

import com.party.common.paging.Page;
import com.party.core.dao.read.commune.CIntegralItemReadDao;
import com.party.core.dao.write.commune.CIntegralItemWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.commune.CIntegralItem;
import com.party.core.service.commune.ICIntegralItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @program: party
 * @description: 积分类型服务实现
 * @author: Hua Qunhao
 * @create: 2019-08-12 14:29
 **/
@Service
public class CIntegralItemService implements ICIntegralItemService {
    @Autowired
    private CIntegralItemWriteDao cIntegralItemWriteDao;
    @Autowired
    private CIntegralItemReadDao cIntegralItemReadDao;


    /**
     * @param partnerId
     * @return
     * @Author hzq
     * @Description //根据pmid找到积分列表
     * @Date 15:33 2019/8/13
     **/
    @Override
    public List<CIntegralItem> getCIntegralItemsByPmIdAndTypeId(String partnerId, String typeId, String memberId, Page page) {
        return cIntegralItemReadDao.getCIntegralItemsByPmIdAndTypeId(partnerId, typeId, memberId, page);
    }

    @Override
    public String insert(CIntegralItem cIntegralItem) {
        BaseModel.preInsert(cIntegralItem);
        boolean result = cIntegralItemWriteDao.insert(cIntegralItem);
        if (result) {
            return cIntegralItem.getId();
        }
        return null;
    }

    @Override
    public boolean update(CIntegralItem cIntegralItem) {
        cIntegralItem.setUpdateDate(new Date());
        return cIntegralItemWriteDao.update(cIntegralItem);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        return cIntegralItemWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public CIntegralItem get(String id) {
        return cIntegralItemReadDao.get(id);
    }

    @Override
    public List<CIntegralItem> listPage(CIntegralItem cIntegralItem, Page page) {
        return cIntegralItemReadDao.listPage(cIntegralItem, page);
    }

    @Override
    public List<CIntegralItem> list(CIntegralItem cIntegralItem) {
        return this.listPage(cIntegralItem, null);
    }

    @Override
    public List<CIntegralItem> batchList(Set<String> ids, CIntegralItem cIntegralItem, Page page) {
        return null;
    }


    @Override
    public List<CIntegralItem> webPageList(Map<String, Object> params, Page page) {
        return cIntegralItemReadDao.webPageList(params, page);
    }

    @Override
    public Integer getItemNum(CIntegralItem cIntegralItem) {
        return cIntegralItemReadDao.getItemNum(cIntegralItem);
    }

    @Override
    public List<CIntegralItem> getCIntegralItemsByPmId(String partnerId, String memberId) {
        return cIntegralItemReadDao.getCIntegralItemsByPmId(partnerId, memberId);
    }

    @Override
    public List<CIntegralItem> getItemsByNameAndCategory(Map<String, Object> params) {
        return cIntegralItemReadDao.getItemsByNameAndCategory(params);
    }
}
